package ACM.zijie;

/**
 * @Author wwk
 * @DATE 2022/8/28 10:01
 */
import java.util.*;
public class first {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while(t-->0){
            //输入
            int n = scanner.nextInt();

            int[] nums = new int[n];  //数组存指数
            for(int i = 0; i < n; i++){
                nums[i] =  getZ(scanner.nextInt())-1;
            }
            System.out.println(Arrays.toString(nums));
            //特例
            if(n==1){
                System.out.println(0+ " "+0);
                continue;
            }
            //动态规划，dp[i]记录当前位置最大的,max为最大值
            int max = nums[0];
            int[] dp = new int[n];
            dp[0] = nums[0];
            int end = 0;
            for(int i = 1; i < n; i++){
                if(nums[i]==-1){
                    dp[i] = -1;
                    continue;
                }
                //当前值加前面的和大于当前
                if(nums[i] + dp[i-1] >= nums[i]){
                    dp[i] = nums[i] + dp[i-1];

                }else{
                    dp[i] = nums[i];
                }
                //如果当前值max更大,更新end
                if(dp[i]>max){
                    max = dp[i];
                    end = i;
                }
            }
            int start  = -1;
            for(int i=end; i>=0; i--){
                if(dp[i]==-1){
                    start = i;
                    break;
                }
            }
            //要么前面没有0，一直到开头此时start = -1,我们需要start=1
            if(start==-1){
                start = 1;
            }else{
                start = start + 2;
            }
            System.out.println(start + " "+(end+1));
        }

    }

    private  static int getZ(int num){

        int count = 0;
        while(num>0){
            num /= 2;
            count++;
        }
        return count;
    }
}
